<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>开启复选框</legend>
</fieldset>

<div id="test7" class="demo-tree"></div>

<form class="layui-form" action="">
    <input type="hidden" name="id" value="{$data.id}">

    <div class="layui-form-item">
        <label class="layui-form-label">组名</label>
        <div class="layui-input-block">
            <input type="text" name="title" value="{$data.title}" autocomplete="off" value="{$data.title}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权限库</label>
        <div class="layui-input-block">
            {foreach $rules as $r}
            {$r.s}<input type="checkbox" name="rules[]" value="{$r.id}"  title="{$r.title}"{if in_array($r.id,$data.rules)} checked="checked"{/if}  ><br /><br />
            {/foreach}
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>



</body>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['jquery','form','tree'], function(){
        var jquery = layui.jquery;
        var form = layui.form;
        var tree = layui.tree;

        //监听提交
        form.on('submit(demo)',function(data){
            //alert(data.filed);
            jquery.post("/admin/group/groupUpdateDo",data.field,function(res){
                if(res.code == 1 ){
                    layer.msg('修改成功',{icon:1,time:1000},function(){
                        window.parent.location.reload();
                    });
                }
            });
            return false;
        });
    });
</script>
</html>